﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Runtime.Serialization;
using RATSharp.Rest;
using System.Threading.Tasks;
using RATSharp.Model;
namespace RATSharpW7.ViewModel
{
    /// <summary>
    /// ViewModel for single object
    /// </summary>
    [DataContract]
    public class ObjectProfileViewModel : SingleObjectViewModel<RATSharp.Model.Object, Objects>
    {

        public ObjectProfileViewModel(RATSharp.Model.Object data) : base(data)
        {
        }

        /// <summary>
        /// reload model in case user changed favourite state
        /// </summary>
        /// <param name="favourite">isFavourite</param>
        public void favouriteChange(bool favourite)
        {
            Task<RATSharp.Model.Objects> task;
            if (favourite)
            {
                task = RestService.getInstance().addFavourite(DataSource.id);
            }
            else
            {
                task = RestService.getInstance().removeFavourite(DataSource.id);
            }
            notifyChangeModel(task);
        }


    }
}
